package c.e.b.h.e.k;

import c.e.a.b.b.j.d;
import c.e.a.b.g.g;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;

/* compiled from: CrashlyticsBackgroundWorker */
public class h {
    public final ExecutorService a;
    public g<Void> b = d.b(null);
    public final Object c = new Object();
    public ThreadLocal<Boolean> d = new ThreadLocal();

    /* compiled from: CrashlyticsBackgroundWorker */
    public class a implements Runnable {
        public void run() {
            h.this.d.set(Boolean.TRUE);
        }
    }

    public h(ExecutorService executorService) {
        this.a = executorService;
        executorService.submit(new a());
    }

    public void a() {
        if (!Boolean.TRUE.equals(this.d.get())) {
            throw new IllegalStateException("Not running on background worker thread as intended.");
        }
    }

    public <T> g<T> b(Callable<T> callable) {
        g e;
        synchronized (this.c) {
            e = this.b.e(this.a, new j(this, callable));
            this.b = e.e(this.a, new k(this));
        }
        return e;
    }

    public <T> g<T> c(Callable<g<T>> callable) {
        g f;
        synchronized (this.c) {
            f = this.b.f(this.a, new j(this, callable));
            this.b = f.e(this.a, new k(this));
        }
        return f;
    }
}
